Repository navigation
Conversation
…rows drawn under its mask on the GPU Ripple's CUDA backend had no first_masked, and it refused a grammar stream when it opened and a masked window in verify, so the server reported no structured output for the model (ashhart#5252). The lane core, the grammar window and the server need no change. A grammar's rows are copied on the device (a scratch of a round's rows and their bits, 27.3 MB, opened by the first such row), sample.cu's tf_grammar_mask puts the copy's disallowed tokens at -inf, and the draw and argmax kernels of a row with no grammar draw from the copy. Greedy rows stay on the device: the argmax kernel orders raw bits and takes -inf as the lowest value. The logprob rows read the model's own rows, as on Metal. A row with no grammar runs the launches it ran before, and init allocates the bytes it allocated before. A mask of the wrong length is refused by name (InvalidGrammarMasks) before the forward. The kernel contract holds the launch already (sample tf_grammar_mask, 256 threads). ripple-serve check 7 (GB10, ripple_mask_tests.zig): the first token and a 4-row window under masks (every token, about half, five tokens, all but the plain one), greedy and sampled, each draw against the plain draw over the same row with the other tokens at -inf; the model's rows and logprob rows against those with no mask; streams with no grammar in rounds beside a masked stream against each alone. test-ricursive-cuda-host: the words of a grammar row; the family words no refusal for structured output now. Fixes ashhart#5252.
…alls, as run on GB10 ripple-serve check 7 and the served forms on e1dc05998: the masked draws against the plain draw over the rows with the other tokens at -inf, 11 request forms greedy and sampled, and tool calls by tool_choice auto, required, a named function and a streamed required call. The plain dumps are bit-identical to the 6 November reference's (refs ashhart#5252).
…s, and a control that reads a word's bits from the top ricursive-contract takes sample.cu's tf_grammar_mask as the backend launches it (256 threads, a block a row, the family's vocabulary) at 1, 3, 7, 16 and 128 rows and at the tile's edges: an allowed token keeps its bits, NaN patterns included, and a disallowed token is -inf, word for word. The planted control, tf_ctl_rc_grammar_mask in contract_controls' image, reads token t at bit 31 - t % 32 and must turn the shapes gate red. No served kernel and no launch record changes (refs ashhart#5252).
The backend serves logprob rows (the first token's, a round's and a prompt's); only a thinking budget is refused by name (refs ashhart#5252).
7 of 8 tasks
Owner
|
Thank you, @jrb-ai. This looks safe for a runtime A/B. Masked draws keep allowed BF16 values and original logprob rows intact; unmasked requests keep their old path.
|
ashhart
pushed a commit
to jrb-ai/TensorFold
that referenced
this pull request
Nov 28, 2026
jrb-ai
added a commit
to jrb-ai/TensorFold
that referenced
this pull request
Nov 28, 2026
jrb-ai
added a commit
to jrb-ai/TensorFold
that referenced
this pull request
Nov 28, 2026
jrb-ai
added a commit
to jrb-ai/TensorFold
that referenced
this pull request
Nov 28, 2026
ashhart
pushed a commit
to jrb-ai/TensorFold
that referenced
this pull request
Nov 29, 2026
ashhart
pushed a commit
to jrb-ai/TensorFold
that referenced
this pull request
Nov 29, 2026
ashhart
pushed a commit
to jrb-ai/TensorFold
that referenced
this pull request
Nov 30, 2026
ashhart
pushed a commit
to jrb-ai/TensorFold
that referenced
this pull request
Nov 30, 2026
ashhart
pushed a commit
to jrb-ai/TensorFold
that referenced
this pull request
Nov 30, 2026
ashhart
pushed a commit
to jrb-ai/TensorFold
that referenced
this pull request
Nov 30, 2026
jrb-ai
added a commit
to jrb-ai/TensorFold
that referenced
this pull request
Dec 2, 2026
jrb-ai
added a commit
to jrb-ai/TensorFold
that referenced
this pull request
Dec 2, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Before, Ripple-65B-Preview on CUDA refused
response_format, theguided_*andstructured_outputsfields and aforced tool call (
tool_choice"required"or a named function) with HTTP 400: the CUDAricursivebackend had nofirst_masked, and it refused a grammar stream and a masked verify window. After, it serves them. A grammar's rowsare copied on the device,
tf_grammar_maskputs the copy's disallowed tokens at -inf, and the draw and argmaxkernels of a row with no grammar draw from the copy. Logprob rows read the model's own rows, as on Metal.
A request with no grammar runs the launches it ran before, and the backend allocates the bytes it allocated before:
the scratch for the copies and the mask bits (27.3 MB) is opened by the first grammar row. A mask of the wrong
length is refused by name before the forward.
2713f2791). Five commits:3756de0cb(the backend and its GPU checks),7facf77cc(therecipe's measured lines),
8d2de9f15(the mask's contract case and its planted control, asked for on the issue),577aa2eb5(the recipe's logprob sentence, asked for on the issue) and1f475e66d(this PR's number in thechangelog line).
atc overlap --base upstream/main --json(27 Nov, main at5b34fabfe, 68 commits past this PR's base; the branchmerges clean with it): incomplete (
pullRequestsLimit,otherPullRequestsLimit,pullFilesUnavailable,timeLimit). Of the open PRs it read that share a file with this one, qwen27: serve the 27B pair, refuse what a pair cannot keep, and die with the peer #1434, hip: ModelOpt NVFP4 and FP8 checkpoints keep their codes and decode in flight #2490, ricursive: serve Ripple-65B on two GB10s with up to 1M tokens of context #2522, test(cuda): opt-in --jobs and --shard for kernel-contract #3093 and dsv41 cuda: the KV pool's family tensors come from the display carveout first #3592 mergeclean, and Unlimited-OCR-2 on CUDA: the family's steps on NVIDIA GPUs (sm_89 and up) #2077, flashnext cuda: the opt-in --tp 2 decode graph takes the dense split and keeps its graph across drafted verifies #2982 and flashnext ranks: every byte after the key proof crosses the pair's link in sealed records #3076 were not tried in the time limit. Implement GLP control vectors with a fused Metal kernel for Qwen3.8-27B #1835, app: control vector picker and strength in Engine advanced #1951 and glm cuda: TF_GLM_COPY_SHARE=1 lets shared rounds' copies take the lone ramp, to a stream's share of the rows #3333 conflict in
CHANGELOG.mdonly (each adds an Unreleased line; this PR's line sits at the end of Unreleased). ricursive: speed up Ripple-65B on two GB10s #2523 conflictsin
zig/tests/cuda/main_usage.zigonly (this PR rewords thericursive-contractusage line). ricursive: load Ripple's EXL3 packs through main's shared EXL3 code #2514 (stacked onricursive: Ripple-65B-Preview's DFlash2 drafter on native CUDA #2475) conflicts in three files that ricursive: Ripple-65B-Preview's DFlash2 drafter on native CUDA #2475 also changes. ricursive: Ripple-65B-Preview's DFlash2 drafter on native CUDA #2475 is mine: I rebased it on this branch, with those
lines merged, and it is stacked on this PR.
Checks on this head
1f475e66d. The GB10 build, the family suites, the plain dumps and the served checks ran on7facf77cc, this PR's second commit. The head adds three commits to it: the contract case (test files and onecontrol kernel in
contract_controls' image; no served kernel and no backend line), one recipe sentence and thechangelog line's PR number. The contract case ran on GB10 in ricursive: Ripple-65B-Preview's DFlash2 drafter on native CUDA #2475's tree (
1353bbd55), which holds this PR'sfirst four commits unchanged. A run of the head alone follows; the recipe's
SUMMARYline is from7facf77ccuntil then (see Kernel contract). The Mac suite ran on
7facf77cc; the host test, the Linux compile and thecheckers below ran on
577aa2eb5, which the head differs from by the changelog line.tools/zig/lean_new.py).tools/pr_check.py --base 2713f2791 --pr 5363on the head: 0 errors.zig fmt --check build.zig zigandgit diff --check: clean.tools/zig/cuda_common_check.py: 0 violations;tools/zig/cuda_fragment_check.py: 0 misses.zig build test test-kernel-contract test-golden -Dcpu=apple_m1from an empty cache, on7facf77cc: 1,158 of 1,163 steps; 18,999 of 19,155 tests pass, 153 skip, 3 fail. The base2713f2791gives thesame result on this Mac but for this PR's one host test (18,998 of 19,154; 153 skip; the same 3 fail): two
Inkling 2 Metal tests ("Mini pre-fusion skips only visit 0 ..." and "48-visit Inkling 2 Mini Metal verify tree
...") and "info prices a Qwen3.8-27B start from serve's charge ...", and the same failed build step (
lfm3'stests, "no module named 'rope_freq'").
zig build test-ricursive-cuda-host: 42 of 42. The Linux binaries andGPU tests compile from the Mac on the head (
zig build compile-cuda-tests compile-cuda-cli native -Dtarget=aarch64-linux-gnu): 25 of 25 steps.tf-cuda-teston7facf77cc:ripple-serve13 passed, 0 failed, with check 7's four lines (below);ripple-forward35 and 0;ricursive-contract20 kernels pass gates 1-4, 0 fail, 24 controls red as planted, 0missed.
served kernel is new or changed; the one new launch is
tf_grammar_maskat 256 threads, a block a row, which theregistry holds as "sample tf_grammar_mask".
tools/bench_concurrent.pyandtools/bench_openai.py: see Receiptfor what ran in their place.
Receipt
prompt chunks of 2,048 and 333 rows and for one-row decode, against the reference dumps that main gives too
(main
e63912221on 26 Nov; this branch at7facf77ccon 27 Nov); the 256-token greedy run's token hash isequal.
2713f2791and this branch, Zig 0.17.0, CUDA 13 (nvcc 13.3, V13.3.73), DGX Spark(GB10, sm_121, 121.7 GiB shared with the host),
ricursiveAI/Ripple-65B-Preview-NVFP4at99eea4477a001a41b86914e41feb4b2ed86105e5,--context 32768.libtfgrammarfrom the 1.2.2 release archive (theserver logs "structured output: xgrammar over 100352 tokens"). Mac: M5 Pro, 48 GB.
ricursivebackend's first draw and verify windows of a streamwith a grammar. A stream with no grammar takes the branch it took before (
mask.len == 0,w.masks.len == 0).Metal, the lane core, the grammar window and the server are not changed. Run: sm_121. Not run: sm_80, 86, 89, 120.
ripple-servecheck 7, greedy andsampled at temperature 1, top-p 0.95, top-k 20):
verify window under masks (every token allowed, about half, five tokens, all but the plain draw's token) each
equal the plain draw over the same row with its disallowed tokens at -inf. A greedy draw also equals the first
largest allowed logit, picked on the host.
and each logprob row equals a float64 log-softmax of the unmasked row (ids exact, values within 2e-6).
their logits each, equal to each stream alone.
InvalidGrammarMasks) before the forward.7facf77cc(the recipe's served checks, 157 requests): 11 request forms(
response_formatjson_object and json_schema;guided_json,guided_regex,guided_choice,guided_grammar;structured_outputsjson, json_object, regex, choice, grammar), each greedy and sampled (seed 7): 44 requests,every reply valid for its form, each equal to its repeat. Tool calls with
tool_choice"auto","required"and a named function, and a streamed required call: all call the function with JSON arguments, and the streamed
arguments equal the reply sent whole. On main the same script gets HTTP 400 for the 11 forms and for both forced
choices (run on 26 Nov). The other served checks pass unchanged (seeded repeats, 60 repeats of a reply,
streaming, multi-turn resumes, stop strings,
max_tokens, verbatim copies, logprob rows): 10 pass, 0 fail, 1skipped (the long-prompt check, which needs a token file).
8 structured requests, greedy and sampled, each alone, then 2 at once, then 8 at once: 36 replies, each valid for
its form and equal to the same request alone.
1353bbd55, stacked on this PR; not part of this PR), on GB10:--drafterserver against this PR's plain server: 157 of 157 requests of the served checks equal by status,finish reason and reply hash, 44 structured and 5 tool requests among them. On the structured requests 233 of
499 drafts were accepted (386 tokens in 135 rounds, against 402 tokens in 376 rounds with
"draft": false).--drafterserver, alone, 2 at once and 8 at once. Every reply equals the plain server's, and the server's log shows 158
of 339, 42 of 89 and 149 of 365 drafts accepted at the three levels.
e63912221(26 Nov) and 248.201 ms on7facf77cc(27 Nov; 247.726 ms on this PR's first form the same morning).tools/bench_openai.pywas not run: a request with no grammar runs the same launches as on main.Kernel contract
tf_grammar_mask(sample.cu, a kernelmain already serves; its launch record "sample tf_grammar_mask" is unchanged) joins
ricursive-contractas thebackend launches it: 256 threads, a block a row, the family's vocabulary, at 1, 3, 7, 16 and 128 rows and at the
tile's edges. It replaces none. Its rule: an allowed token keeps its bits, NaN patterns included; a disallowed
token is -inf, word for word.
tf_ctl_rc_grammar_mask(
contract_controls' image) reads token t at bit 31 - t % 32 of its word. It is red at the shapes gate, asplanted ("at 128x100352x1: row 0 token 2: c0b0 where ff80 is due").
SUMMARYline and exit status: CUDA (GB10), exit 0, in ricursive: Ripple-65B-Preview's DFlash2 drafter on native CUDA #2475's tree (1353bbd55), which has twokernels and three controls of its own beside this PR's:
SUMMARY ricursive: 23 kernels, 23 pass gates 1-4, 0 fail; 28 controls: 28 red as planted, 0 missedThe mask's lines: nonfinite PASS (the stated rule holds), repeat PASS (five runs byte-identical, 12,845,056
bytes), shapes PASS (9 shapes exact, 0 edges refused), sums n/a. On
7facf77cc, before the case:SUMMARY ricursive: 20 kernels, 20 pass gates 1-4, 0 fail; 24 controls: 24 red as planted, 0 missedChecklist
The title and description match the head commit, including the receipt and the stack.
New tests fail before the change, pass after it, and skip cleanly without their dependency. (The GPU checks
and the host test do not build on main, which has no
first_maskedand nomaskWords; the served script getsHTTP 400 on main. The mask's contract case passes on main too: the kernel is main's.)
Comments and docstrings are one line. No measurements or history in the source.
No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.
Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
Drafted output equals
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (Thefirst and the third hold under a grammar, as measured above. A resumed prompt under a grammar was not measured;
without a grammar the multi-turn check passes unchanged.)
No precision traded for speed. If the bits change, the description says which sums change and why.
Decode and prompt processing are no slower than main at one stream and the widest admitted; with
--drafter, no slower than without it, greedy and sampled (One stream: 247.954 ms a token on main, 248.201 ms here, inside theday's spread of 247.7 to 248.3. Eight streams were not timed; a request with no grammar runs main's launches.)
Authored by JRB AI in a private capacity. This contribution does not represent the views or positions of any organisation.